package com.betterjr.modules.contract.entity;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import com.betterjr.common.annotation.MetaData;
import com.betterjr.common.entity.BetterjrEntity;
import com.betterjr.common.selectkey.SerialGenerator;
import com.betterjr.common.utils.BetterDateUtils;

@Access(AccessType.FIELD)
@Entity
@Table(name = "t_contract_signatory")
public class ContractSignatory implements BetterjrEntity {
    /**
     * 编号
     */
    @Id
    @Column(name = "ID", columnDefinition = "INTEGER")
    @MetaData(value = "编号", comments = "编号")
    private Long id;

    /**
     * 业务单号
     */
    @Column(name = "C_REQUESTNO", columnDefinition = "VARCHAR")
    @MetaData(value = "业务单号", comments = "业务单号")
    private String requestno;

    /**
     * 协议编号
     */
    @Column(name = "L_PROTOCOL_LIST_ID", columnDefinition = "INTEGER")
    @MetaData(value = "协议编号", comments = "协议编号")
    private Long protocolListId;

    /**
     * 签署方机构名称编号
     */
    @Column(name = "C_SIGNATORY_ORGANIZATION_ID", columnDefinition = "LONG")
    @MetaData(value = "签署方机构名称", comments = "签署方机构名称")
    private String signatoryOrganizationId;

    /**
     * 签署方机构名称
     */
    @Column(name = "C_SIGNATORY_ORGANIZATION", columnDefinition = "VARCHAR")
    @MetaData(value = "签署方机构名称", comments = "签署方机构名称")
    private String signatoryOrganization;

    /**
     * 签署人
     */
    @Column(name = "C_SIGNATORY_NAME", columnDefinition = "VARCHAR")
    @MetaData(value = "签署人", comments = "签署人")
    private String name;

    /**
     * 签署人手机
     */
    @Column(name = "C_SIGNATORY_PHONE", columnDefinition = "VARCHAR")
    @MetaData(value = "签署人手机", comments = "签署人手机")
    private String mobileNo;

    /**
     * 签署人邮箱
     */
    @Column(name = "C_SIGNATORY_EMAIL", columnDefinition = "VARCHAR")
    @MetaData(value = "签署人邮箱", comments = "签署人邮箱")
    private String email;

    @Column(name = "C_SIGNATURE_LOCATION", columnDefinition = "VARCHAR")
    @MetaData(value = "签署位置", comments = "签署位置")
    private String signatory;

    /**
     * 登记日期
     */
    @Column(name = "D_REG_DATE", columnDefinition = "VARCHAR")
    @MetaData(value = "登记日期", comments = "登记日期")
    private String regDate;

    /**
     * 登记时间
     */
    @Column(name = "T_REG_TIME", columnDefinition = "VARCHAR")
    @MetaData(value = "登记时间", comments = "登记时间")
    private String regTime;

    private static final long serialVersionUID = 1508984350833L;

    public Long getId() {
        return id;
    }

    public void setId(final Long anId) {
        id = anId;
    }

    public String getRequestno() {
        return requestno;
    }

    public void setRequestno(final String anRequestno) {
        requestno = anRequestno;
    }

    public Long getProtocolListId() {
        return protocolListId;
    }

    public void setProtocolListId(final Long anProtocolListId) {
        protocolListId = anProtocolListId;
    }

    public String getSignatoryOrganizationId() {
        return signatoryOrganizationId;
    }

    public void setSignatoryOrganizationId(final String anSignatoryOrganizationId) {
        signatoryOrganizationId = anSignatoryOrganizationId;
    }

    public String getSignatoryOrganization() {
        return signatoryOrganization;
    }

    public void setSignatoryOrganization(final String anSignatoryOrganization) {
        signatoryOrganization = anSignatoryOrganization;
    }

    public String getName() {
        return name;
    }

    public void setName(final String anName) {
        name = anName;
    }

    public String getMobileNo() {
        return mobileNo;
    }

    public void setMobileNo(final String anMobileNo) {
        mobileNo = anMobileNo;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(final String anEmail) {
        email = anEmail;
    }

    public String getSignatory() {
        return signatory;
    }

    public void setSignatory(final String anSignatory) {
        signatory = anSignatory;
    }

    public String getRegDate() {
        return regDate;
    }

    public void setRegDate(final String anRegDate) {
        regDate = anRegDate;
    }

    public String getRegTime() {
        return regTime;
    }

    public void setRegTime(final String anRegTime) {
        regTime = anRegTime;
    }

    @Override
    public String toString() {
        return "ContractSignatory [id=" + id + ", requestno=" + requestno + ", protocolListId=" + protocolListId
                + ", signatoryOrganizationId=" + signatoryOrganizationId + ", signatoryOrganization="
                + signatoryOrganization + ", name=" + name + ", mobileNo=" + mobileNo + ", email=" + email
                + ", signatory=" + signatory + ", regDate=" + regDate + ", regTime=" + regTime + "]";
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (email == null ? 0 : email.hashCode());
        result = prime * result + (id == null ? 0 : id.hashCode());
        result = prime * result + (mobileNo == null ? 0 : mobileNo.hashCode());
        result = prime * result + (name == null ? 0 : name.hashCode());
        result = prime * result + (protocolListId == null ? 0 : protocolListId.hashCode());
        result = prime * result + (regDate == null ? 0 : regDate.hashCode());
        result = prime * result + (regTime == null ? 0 : regTime.hashCode());
        result = prime * result + (requestno == null ? 0 : requestno.hashCode());
        result = prime * result + (signatory == null ? 0 : signatory.hashCode());
        result = prime * result + (signatoryOrganization == null ? 0 : signatoryOrganization.hashCode());
        result = prime * result + (signatoryOrganizationId == null ? 0 : signatoryOrganizationId.hashCode());
        return result;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        ContractSignatory other = (ContractSignatory) obj;
        if (email == null) {
            if (other.email != null) return false;
        } else if (!email.equals(other.email)) return false;
        if (id == null) {
            if (other.id != null) return false;
        } else if (!id.equals(other.id)) return false;
        if (mobileNo == null) {
            if (other.mobileNo != null) return false;
        } else if (!mobileNo.equals(other.mobileNo)) return false;
        if (name == null) {
            if (other.name != null) return false;
        } else if (!name.equals(other.name)) return false;
        if (protocolListId == null) {
            if (other.protocolListId != null) return false;
        } else if (!protocolListId.equals(other.protocolListId)) return false;
        if (regDate == null) {
            if (other.regDate != null) return false;
        } else if (!regDate.equals(other.regDate)) return false;
        if (regTime == null) {
            if (other.regTime != null) return false;
        } else if (!regTime.equals(other.regTime)) return false;
        if (requestno == null) {
            if (other.requestno != null) return false;
        } else if (!requestno.equals(other.requestno)) return false;
        if (signatory == null) {
            if (other.signatory != null) return false;
        } else if (!signatory.equals(other.signatory)) return false;
        if (signatoryOrganization == null) {
            if (other.signatoryOrganization != null) return false;
        } else if (!signatoryOrganization.equals(other.signatoryOrganization)) return false;
        if (signatoryOrganizationId == null) {
            if (other.signatoryOrganizationId != null) return false;
        } else if (!signatoryOrganizationId.equals(other.signatoryOrganizationId)) return false;
        return true;
    }

    public void initValue() {
        this.id = SerialGenerator.getLongValue("ContractSignatory.id");
        this.regDate = BetterDateUtils.getNumDate();
        this.regTime = BetterDateUtils.getNumTime();
    }
}